package io.polly.ldz.webflux.filter;


import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;

/**
 * @author ldz11
 * @description：
 * @date 2025/3/12 12:16
 */
@Component
public class PollyWebFilter implements WebFilter {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {

        System.out.println("请求处理放行到目标方法之前。。。");


        Mono<Void> mono = chain.filter(exchange)//异步
                .doOnError(err-> System.out.println(err.getMessage()+"目标方法异常以后..."))
                .doFinally(signalType -> System.out.println("请求处理放行到目标方法之后。。"));
        return mono;
    }
}
